package web.servlet.dto;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import data.model.ChatMessage;
import data.model.Group;
import data.model.Membership;

public class DtoFactory {

    public static Map<String, Object> createMessage(String message) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("message", message);
        return result;
    }

    public static Map<String, Object> createErrorMessage(String message) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", false);
        result.put("errorMessage", message);
        return result;
    }

    public static Map<String, Object> createValidateEmailSuccess() {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        return result;
    }

    public static Map<String, Object> createLoginSuccess(String accessToken) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("accessToken", accessToken);
        return result;
    }

    public static Map<String, Object> createNewGroupResponse(String groupId, String groupName, String owner, String role) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("groupId", groupId);
        result.put("groupName", groupName);
        result.put("owner", owner);
        result.put("role", role);
        return result;
    }

    public static Map<String, Object> createGroupList(List<Group> groups) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("groups", groups);
        return result;
    }

    public static Map<String, Object> createMembershipList(List<Membership> memberships) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("memberships", memberships);
        return result;
    }

    public static Map<String, Object> createMessageList(List<ChatMessage> messages, long messageCounter) {
        final Map<String, Object> result = new HashMap<String, Object>();
        result.put("success", true);
        result.put("messages", messages);
        result.put("messageCounter", messageCounter);
        return result;
    }

}
